package com.ttg.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;

/**
 * 优惠券用户token 状态
 *
 * @author CZW
 * @date 2021/12/04 16:01
 **/
public enum CouponVipTokenStatusEnum {
    INVALID(0, "无效"),
    EFFECTIVE(1, "有效"),
    TIME_OUT(2, "超时下线"),
    USER_LOGIN_OUT(3, "主动下线"),
    SYS_LOGIN_OUT(4, "被踢下线");

    @EnumValue
    @JsonValue
    private Integer value;
    private String desc;

    CouponVipTokenStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    private static final Map<Integer, CouponVipTokenStatusEnum> VALUES = new HashMap<>();

    static {
        for (final CouponVipTokenStatusEnum type : CouponVipTokenStatusEnum.values()) {
            CouponVipTokenStatusEnum.VALUES.put(type.getValue(), type);
        }
    }

    @JsonCreator
    public static CouponVipTokenStatusEnum of(Integer code) {
        return CouponVipTokenStatusEnum.VALUES.get(code);
    }
}
